<?php

class helper_validation
{
	//public $error = array();

	private $check = TRUE;

	public function valid_email($str)
	{
		if(! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str))
		{
			$this->check = FALSE;
			return FALSE;
		}
		return TRUE;
	}

	public function min_length($str, $val)
	{
		if (preg_match("/[^0-9]/", $val))
		{
			return FALSE;
		}

		return (strlen($str) < $val) ? FALSE : TRUE;
	}

	public function is_numeric($str)
	{
		if(! is_numeric($str))
		{
			$this->check = FALSE;
			return FALSE;
		}
		return TRUE;
	}

	public function required($str)
	{
		if (is_string($str))
		{
			if(trim($str) == '')
			{
				$this->check = FALSE;
				return FALSE;
			}
			return TRUE;
		}
	}

	public function max_length($str, $val)
	{
		if (preg_match("/[^0-9]/", $val))
		{
			return FALSE;
		}

		return (strlen($str) > $val) ? FALSE : TRUE;
	}

	public function check()
	{
		return $this->check;
	}
}

/* End of file helper_validation.php */
/* Location: .//D/xampp/htdocs/my_framework/helpers/helper_validation.php */
